// const http = require('http')
// const server = http.createServer((req, res) => {
//     if (req.url == '/favicon.ico') return;
//     res.writeHead(200, { 'content-type': 'text/html;charset=utf-8' })
//     if (req.url == '/') {
//         res.end('正常')
//     }
/*
request
url
      headers
    pathName
    method
    htmlVersion
response
    write
    end
    writeHead
    statusCode

 fs
    文件夹
    readdir
    mkdir
    rmdir
    文件
    writeFile
    appendFile
    readFile
    unlink
url
    parse(req.url,true)
    format(obj)
path
__filename
__dirname
    basename
    extname
    dirname
    jion
    resolve

addListener('date',(r)=>{
    str+=r
})
addListener('end'r=>{
    str.split()
})

------------
express

/^$/
ab+cd
sb*sd
sb(sd)?e
get 
post
all


request
    query   ?
    params  :
    ip
    hostname
    body
        cnpm i body-parser
        bodyParser = require('body-parser')
        app.use(bodyParser.urlencoded({extended:true})) 


response
    end
    send
    json
    sendFile
    status(200).end()
    download
    cookie
    clearcookie
    redirect
    render ejs
        cpm i render 
        app.set('ejs engine' ,'ejs' )
        app.set('views,'./vs')
        html
        app.engine('./html',require('ejs).__express)
        app.set('view engine','html)
    app.render(path,obj)
    app.use(express.static(path))

    */

// })
// server.listen(80, 'localhost', r => { console.log('服务器 localhost 端口 80') })

const express = require('express')
const app = express()
const fs = require('fs')

app.get('/', (req, res) => {
    fs.readFile('./btn.html', (err, data) => {
        if (err) throw err;
        res.end(data)
    })
})
app.get('/btn', (req, res) => {
    let str = []
    let ht = ``
    fs.readdir('../assets/icon/svg', (err, data) => {
        if (err) throw err;
        data.map(r => {
            // fs.readFile('../assets/icon/svg/' + r, (err, data) => {
            //     ht += data
            // })
            str.push(r.slice(0, -4))

        })
        res.json(str)
        // fs.writeFile('../assets/icon/name.txt', str, (err) => {
        //     if (err) { console.log('写入失败'); }
        // })
        // console.log(data[0].slice(0, -4));
    })

})

app.listen(80)
console.log('服务器 localhost 端口 80');